/*
 * Copyright � 2008 Nokia Corporation.
 */


#ifndef SUDOKUGRIDCONTROL_H
#define SUDOKUGRIDCONTROL_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <coecntrl.h>

// CLASS DECLARATION

class CSudokuContainerControl;
class CFbsBitGc;
class CSudokuGameLogic;
class CGraphicEngine;
class TGridItem;

class CSudokuGridControl : public CCoeControl
    {
    public:
        ~CSudokuGridControl ( );
        static CSudokuGridControl* NewL (CSudokuContainerControl& aParent, const TRect& aRect,CFbsBitGc*& aBgc);
        static CSudokuGridControl* NewLC (CSudokuContainerControl& aParent, const TRect& aRect,CFbsBitGc*& aBgc);
    
    public:
        void CSudokuGridControl::NumberBtnPressed(TInt aValue);
        inline TPoint ActiveItemPoint(){return iActiveItemPoint;};
        void UpdateCellAnim();        
        void ResetCellAnim();
        
    private:
        CSudokuGridControl (CSudokuContainerControl& aParent, CFbsBitGc*& aBgc);
        void ConstructL (const TRect& aRect);

    private:
        void Draw( const TRect& aRect ) const;
        void DrawGrid() const;
        void DrawGridLines() const;
        void SizeChanged();
        void HandlePointerEventL(const TPointerEvent& aPointerEvent);
        TBool IsActiveItem(TGridItem& aItem) const;

    public:
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
        
    private:
        CFbsBitGc*&                 iBgc;
        CSudokuContainerControl&    iParent;
        CSudokuGameLogic*           iGameLogic;
        
        TPoint                      iActiveItemPoint;
        CGraphicEngine*             iGraphicEngine;
        const CFont*                iNormalFont;
        
        TInt                        iGridAreaHeight;
        TInt                        iGridAreaWidth;
        
        TInt                        iInvalidCellAnim;
        TInt                        iInvalidCellAnimMax;
        
        TRgb                        iRed;                     
    };

#endif // SUDOKUGRIDCONTROL_H
